Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add organization id to the provider. #110

Merged
merged 4 commits into from
Dec 3, 2020
Merged

Conversation

medains
Copy link
Contributor

@medains medains commented Aug 5, 2020

Use the change in grafana/grafana-api-golang-client#9 (previous submitted to nytm/go-grafana-api#62) to
apply an organization id to the provider.

Usage might look like this:

provider "grafana" {
  url = "someurl"
  auth = "adminuser:somepass"
}

resource "grafana_organization" "neworg" {
  name = "neworg"
  admin = "neworgadmin"
}

provider "grafana" {
  alias = "neworg"
  url = "someurl"
  auth = "neworgadmin:somepass"
  org_id = grafana_organization.neworg.org_id
}

resource "grafana_data_source" "neworg_graphite" {
  provider = grafana.neworg
  type = "graphite"
  name = "neworg-graphite"
}

Co-authored-by: hansnqyr [email protected]

This is obviously dependent on the go-grafana-api PR, and addresses the same issue that @bcampoli was addressing in https://github.com/terraform-providers/terraform-provider-grafana/pull/60

@ghost ghost added size/XS labels Aug 5, 2020
@trotttrotttrott
Copy link
Member

@medains this looks great, but we've changed the provider to https://github.com/grafana/grafana-api-golang-client since you opened it. This is so we can have folks in the grafana org help with maintenance. Do you mind opening a PR on that repo? And then also rebasing master here?

@medains
Copy link
Contributor Author

medains commented Oct 15, 2020

Will do, thanks.

@medains
Copy link
Contributor Author

medains commented Oct 16, 2020

Updated, rebased and the PR opened on the new client repo.

@medains
Copy link
Contributor Author

medains commented Oct 28, 2020

Updates, rebased and applied changes based on the now-accepted change to the client api

Use the change in grafana/grafana-api-golang-client#9 to
apply an organization id to the provider.

Usage might look like this:

```hcl
provider "grafana" {
  url = "someurl"
  auth = "adminuser:somepass"
}

resource "grafana_organization" "neworg" {
  name = "neworg"
  admin = "neworgadmin"
}

provider "grafana" {
  alias = "neworg"
  url = "someurl"
  auth = "neworgadmin:somepass"
  org_id = grafana_organization.neworg.org_id
}

resource "grafana_data_source" "neworg_graphite" {
  provider = grafana.neworg
  type = "graphite"
  name = "neworg-graphite"
}
```

Co-authored-by: hansnqyr <[email protected]>
@qvistgaard
Copy link

Any chance for this to be merged in the near future?

@medains
Copy link
Contributor Author

medains commented Nov 18, 2020

@trotttrotttrott - the api changes got merged a while ago, can we get this merged now?

@Merenon
Copy link

Merenon commented Nov 26, 2020

Yes, also very looking forward into this change being merged!

@medains
Copy link
Contributor Author

medains commented Nov 27, 2020

Noticed when using this in anger that the schema TypeInt conversion to int64 for the api library needed a bit of work.

Copy link
Member

@trotttrotttrott trotttrotttrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @medains!

Noticed when using this in anger that the schema TypeInt conversion to int64 for the api library needed a bit of work.

Could you elaborate on this?

@trotttrotttrott trotttrotttrott merged commit 220d7ec into grafana:master Dec 3, 2020
@medains
Copy link
Contributor Author

medains commented Dec 4, 2020

Thanks @medains!

Noticed when using this in anger that the schema TypeInt conversion to int64 for the api library needed a bit of work.

Could you elaborate on this?

Yes:

Thanks @medains!

Noticed when using this in anger that the schema TypeInt conversion to int64 for the api library needed a bit of work.

Could you elaborate on this?

The previous code d.Get("org_id").(int64) gives an error something like "interface{} is type int not int64" - due to the "TypeInt" schema definition. Since there's no "TypeInt64", this conversion is needed.
I found similar solutions to this issue in the aws provider, like here:
https://github.com/hashicorp/terraform-provider-aws/blob/master/aws/resource_aws_ssm_maintenance_window.go#L85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants